minetest.register_node("underworld:stone", {
    description = "Underworld Stone",
    tiles = {"underworld_stone.png"},
    is_ground_content = true,
    groups = {cracky = 3, level = 2},
    sounds = default.node_sound_stone_defaults(),
})

minetest.register_node("underworld:brick", {
    description = "Underworld Brick",
    tiles = {"underworld_brick.png"},
    is_ground_content = false,
    groups = {cracky = 2, level = 2},
    sounds = default.node_sound_stone_defaults(),
})

if minetest.get_modpath("stairs") then
    stairs.register_stair_and_slab(
        "underworld_stone",
        "underworld:stone",
        {cracky = 3, level = 2},
        {"underworld_stone.png"},
        "Underworld Stone Stairs",
        "Underworld Stone Slab",
        default.node_sound_stone_defaults()
    )
    
    stairs.register_stair_and_slab(
        "underworld_brick",
        "underworld:brick",
        {cracky = 3, level = 2},
        {"underworld_brick.png"},
        "Underworld Brick Stairs",
        "Underworld Brick Slab",
        default.node_sound_stone_defaults()
    )
end

if minetest.get_modpath("tnt") then
    local function stone_explode(pos)
        tnt.boom(pos, {radius = 5, disable_drops = true})
        minetest.set_node(pos, {name = "default:lava_source"})
    end
    
    minetest.register_node("underworld:exploding_stone", {
        description = "Exploding Underworld Stone",
        tiles = {"underworld_stone.png^[colorize:red:63"},
        sounds = default.node_sound_stone_defaults(),
        diggable = false,
        light_source = math.floor(minetest.LIGHT_MAX / 4),
        groups = {cracky = 3, level = 2, flammable = 5},
        
        on_punch = stone_explode,
        on_rightclick = stone_explode,
        on_blast = stone_explode,
        on_burn = stone_explode,
        on_ignite = stone_explode,
    })
end

minetest.register_craft({
    output = "underworld:brick 4",
    recipe = {
        {"underworld:stone", "underworld:stone"},
        {"underworld:stone", "underworld:stone"},
    },
})

minetest.register_node("underworld:gravel", {
    description = "Underworld Gravel",
    tiles = {"underworld_gravel.png"},
    is_ground_content = true,
    groups = {crumbly = 3, level = 2, falling_node = 1, flammable = 3},
    sounds = default.node_sound_gravel_defaults(),
})

minetest.register_node("underworld:crystal", {
    description = "Underworld Crystal",
    tiles = {"underworld_crystal.png"},
    is_ground_content = true,
    groups = {cracky = 1, level = 3},
    light_source = minetest.LIGHT_MAX,
    sounds = default.node_sound_glass_defaults(),
})